{
 "cells": [
  {
   "cell_type": "raw",
   "metadata": {},
   "source": [
    "PCA实战task：\n",
    "1、基于iris_data.csv数据，建立KNN模型实现数据分类（n_neighbors=3）\n",
    "2、对数据进行标准化处理，选取一个维度可视化处理后的效果\n",
    "3、进行与原数据等维度PCA，查看各主成分的方差比例\n",
    "4、保留合适的主成分，可视化降维后的数据\n",
    "5、基于降维后数据建立KNN模型，与原数据表现进行对比"
   ]
  },
  {
   "cell_type": "raw",
   "metadata": {},
   "source": [
    "@Author  : Flare Zhao\n",
    "@Email: 454209979@qq.com\n",
    "@QQ讨论群：530533630  申请加群的验证信息为订单号（粘贴号码数字即可）"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>sepal length</th>\n",
       "      <th>sepal width</th>\n",
       "      <th>petal length</th>\n",
       "      <th>petal width</th>\n",
       "      <th>target</th>\n",
       "      <th>label</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>5.1</td>\n",
       "      <td>3.5</td>\n",
       "      <td>1.4</td>\n",
       "      <td>0.2</td>\n",
       "      <td>Iris-setosa</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>4.9</td>\n",
       "      <td>3.0</td>\n",
       "      <td>1.4</td>\n",
       "      <td>0.2</td>\n",
       "      <td>Iris-setosa</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>4.7</td>\n",
       "      <td>3.2</td>\n",
       "      <td>1.3</td>\n",
       "      <td>0.2</td>\n",
       "      <td>Iris-setosa</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>4.6</td>\n",
       "      <td>3.1</td>\n",
       "      <td>1.5</td>\n",
       "      <td>0.2</td>\n",
       "      <td>Iris-setosa</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>5.0</td>\n",
       "      <td>3.6</td>\n",
       "      <td>1.4</td>\n",
       "      <td>0.2</td>\n",
       "      <td>Iris-setosa</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   sepal length  sepal width  petal length  petal width       target  label\n",
       "0           5.1          3.5           1.4          0.2  Iris-setosa      0\n",
       "1           4.9          3.0           1.4          0.2  Iris-setosa      0\n",
       "2           4.7          3.2           1.3          0.2  Iris-setosa      0\n",
       "3           4.6          3.1           1.5          0.2  Iris-setosa      0\n",
       "4           5.0          3.6           1.4          0.2  Iris-setosa      0"
      ]
     },
     "execution_count": 1,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#load data\n",
    "import pandas as pd\n",
    "import numpy as np\n",
    "data = pd.read_csv('iris_data.csv')\n",
    "data.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "     sepal length  sepal width  petal length  petal width          target  \\\n",
      "0             5.1          3.5           1.4          0.2     Iris-setosa   \n",
      "1             4.9          3.0           1.4          0.2     Iris-setosa   \n",
      "2             4.7          3.2           1.3          0.2     Iris-setosa   \n",
      "3             4.6          3.1           1.5          0.2     Iris-setosa   \n",
      "4             5.0          3.6           1.4          0.2     Iris-setosa   \n",
      "..            ...          ...           ...          ...             ...   \n",
      "145           6.7          3.0           5.2          2.3  Iris-virginica   \n",
      "146           6.3          2.5           5.0          1.9  Iris-virginica   \n",
      "147           6.5          3.0           5.2          2.0  Iris-virginica   \n",
      "148           6.2          3.4           5.4          2.3  Iris-virginica   \n",
      "149           5.9          3.0           5.1          1.8  Iris-virginica   \n",
      "\n",
      "     label  \n",
      "0        0  \n",
      "1        0  \n",
      "2        0  \n",
      "3        0  \n",
      "4        0  \n",
      "..     ...  \n",
      "145      2  \n",
      "146      2  \n",
      "147      2  \n",
      "148      2  \n",
      "149      2  \n",
      "\n",
      "[150 rows x 6 columns]\n"
     ]
    }
   ],
   "source": [
    "print(data)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0    0\n",
       "1    0\n",
       "2    0\n",
       "3    0\n",
       "4    0\n",
       "Name: label, dtype: int64"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#define X and y\n",
    "X = data.drop(['target','label'],axis=1)\n",
    "y = data.loc[:,'label']\n",
    "y.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0.96\n"
     ]
    }
   ],
   "source": [
    "#establish knn model and calculate the accuracy\n",
    "from sklearn.neighbors import KNeighborsClassifier\n",
    "KNN = KNeighborsClassifier(n_neighbors=3)\n",
    "KNN.fit(X,y)\n",
    "y_predict = KNN.predict(X)\n",
    "from sklearn.metrics import accuracy_score\n",
    "accuracy = accuracy_score(y,y_predict)\n",
    "print(accuracy)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[[-9.00681170e-01  1.03205722e+00 -1.34127240e+00 -1.31297673e+00]\n",
      " [-1.14301691e+00 -1.24957601e-01 -1.34127240e+00 -1.31297673e+00]\n",
      " [-1.38535265e+00  3.37848329e-01 -1.39813811e+00 -1.31297673e+00]\n",
      " [-1.50652052e+00  1.06445364e-01 -1.28440670e+00 -1.31297673e+00]\n",
      " [-1.02184904e+00  1.26346019e+00 -1.34127240e+00 -1.31297673e+00]\n",
      " [-5.37177559e-01  1.95766909e+00 -1.17067529e+00 -1.05003079e+00]\n",
      " [-1.50652052e+00  8.00654259e-01 -1.34127240e+00 -1.18150376e+00]\n",
      " [-1.02184904e+00  8.00654259e-01 -1.28440670e+00 -1.31297673e+00]\n",
      " [-1.74885626e+00 -3.56360566e-01 -1.34127240e+00 -1.31297673e+00]\n",
      " [-1.14301691e+00  1.06445364e-01 -1.28440670e+00 -1.44444970e+00]\n",
      " [-5.37177559e-01  1.49486315e+00 -1.28440670e+00 -1.31297673e+00]\n",
      " [-1.26418478e+00  8.00654259e-01 -1.22754100e+00 -1.31297673e+00]\n",
      " [-1.26418478e+00 -1.24957601e-01 -1.34127240e+00 -1.44444970e+00]\n",
      " [-1.87002413e+00 -1.24957601e-01 -1.51186952e+00 -1.44444970e+00]\n",
      " [-5.25060772e-02  2.18907205e+00 -1.45500381e+00 -1.31297673e+00]\n",
      " [-1.73673948e-01  3.11468391e+00 -1.28440670e+00 -1.05003079e+00]\n",
      " [-5.37177559e-01  1.95766909e+00 -1.39813811e+00 -1.05003079e+00]\n",
      " [-9.00681170e-01  1.03205722e+00 -1.34127240e+00 -1.18150376e+00]\n",
      " [-1.73673948e-01  1.72626612e+00 -1.17067529e+00 -1.18150376e+00]\n",
      " [-9.00681170e-01  1.72626612e+00 -1.28440670e+00 -1.18150376e+00]\n",
      " [-5.37177559e-01  8.00654259e-01 -1.17067529e+00 -1.31297673e+00]\n",
      " [-9.00681170e-01  1.49486315e+00 -1.28440670e+00 -1.05003079e+00]\n",
      " [-1.50652052e+00  1.26346019e+00 -1.56873522e+00 -1.31297673e+00]\n",
      " [-9.00681170e-01  5.69251294e-01 -1.17067529e+00 -9.18557817e-01]\n",
      " [-1.26418478e+00  8.00654259e-01 -1.05694388e+00 -1.31297673e+00]\n",
      " [-1.02184904e+00 -1.24957601e-01 -1.22754100e+00 -1.31297673e+00]\n",
      " [-1.02184904e+00  8.00654259e-01 -1.22754100e+00 -1.05003079e+00]\n",
      " [-7.79513300e-01  1.03205722e+00 -1.28440670e+00 -1.31297673e+00]\n",
      " [-7.79513300e-01  8.00654259e-01 -1.34127240e+00 -1.31297673e+00]\n",
      " [-1.38535265e+00  3.37848329e-01 -1.22754100e+00 -1.31297673e+00]\n",
      " [-1.26418478e+00  1.06445364e-01 -1.22754100e+00 -1.31297673e+00]\n",
      " [-5.37177559e-01  8.00654259e-01 -1.28440670e+00 -1.05003079e+00]\n",
      " [-7.79513300e-01  2.42047502e+00 -1.28440670e+00 -1.44444970e+00]\n",
      " [-4.16009689e-01  2.65187798e+00 -1.34127240e+00 -1.31297673e+00]\n",
      " [-1.14301691e+00  1.06445364e-01 -1.28440670e+00 -1.44444970e+00]\n",
      " [-1.02184904e+00  3.37848329e-01 -1.45500381e+00 -1.31297673e+00]\n",
      " [-4.16009689e-01  1.03205722e+00 -1.39813811e+00 -1.31297673e+00]\n",
      " [-1.14301691e+00  1.06445364e-01 -1.28440670e+00 -1.44444970e+00]\n",
      " [-1.74885626e+00 -1.24957601e-01 -1.39813811e+00 -1.31297673e+00]\n",
      " [-9.00681170e-01  8.00654259e-01 -1.28440670e+00 -1.31297673e+00]\n",
      " [-1.02184904e+00  1.03205722e+00 -1.39813811e+00 -1.18150376e+00]\n",
      " [-1.62768839e+00 -1.74477836e+00 -1.39813811e+00 -1.18150376e+00]\n",
      " [-1.74885626e+00  3.37848329e-01 -1.39813811e+00 -1.31297673e+00]\n",
      " [-1.02184904e+00  1.03205722e+00 -1.22754100e+00 -7.87084847e-01]\n",
      " [-9.00681170e-01  1.72626612e+00 -1.05694388e+00 -1.05003079e+00]\n",
      " [-1.26418478e+00 -1.24957601e-01 -1.34127240e+00 -1.18150376e+00]\n",
      " [-9.00681170e-01  1.72626612e+00 -1.22754100e+00 -1.31297673e+00]\n",
      " [-1.50652052e+00  3.37848329e-01 -1.34127240e+00 -1.31297673e+00]\n",
      " [-6.58345429e-01  1.49486315e+00 -1.28440670e+00 -1.31297673e+00]\n",
      " [-1.02184904e+00  5.69251294e-01 -1.34127240e+00 -1.31297673e+00]\n",
      " [ 1.40150837e+00  3.37848329e-01  5.35295827e-01  2.64698913e-01]\n",
      " [ 6.74501145e-01  3.37848329e-01  4.21564419e-01  3.96171883e-01]\n",
      " [ 1.28034050e+00  1.06445364e-01  6.49027235e-01  3.96171883e-01]\n",
      " [-4.16009689e-01 -1.74477836e+00  1.37235899e-01  1.33225943e-01]\n",
      " [ 7.95669016e-01 -5.87763531e-01  4.78430123e-01  3.96171883e-01]\n",
      " [-1.73673948e-01 -5.87763531e-01  4.21564419e-01  1.33225943e-01]\n",
      " [ 5.53333275e-01  5.69251294e-01  5.35295827e-01  5.27644853e-01]\n",
      " [-1.14301691e+00 -1.51337539e+00 -2.60824029e-01 -2.61192967e-01]\n",
      " [ 9.16836886e-01 -3.56360566e-01  4.78430123e-01  1.33225943e-01]\n",
      " [-7.79513300e-01 -8.19166497e-01  8.03701950e-02  2.64698913e-01]\n",
      " [-1.02184904e+00 -2.43898725e+00 -1.47092621e-01 -2.61192967e-01]\n",
      " [ 6.86617933e-02 -1.24957601e-01  2.50967307e-01  3.96171883e-01]\n",
      " [ 1.89829664e-01 -1.97618132e+00  1.37235899e-01 -2.61192967e-01]\n",
      " [ 3.10997534e-01 -3.56360566e-01  5.35295827e-01  2.64698913e-01]\n",
      " [-2.94841818e-01 -3.56360566e-01 -9.02269170e-02  1.33225943e-01]\n",
      " [ 1.03800476e+00  1.06445364e-01  3.64698715e-01  2.64698913e-01]\n",
      " [-2.94841818e-01 -1.24957601e-01  4.21564419e-01  3.96171883e-01]\n",
      " [-5.25060772e-02 -8.19166497e-01  1.94101603e-01 -2.61192967e-01]\n",
      " [ 4.32165405e-01 -1.97618132e+00  4.21564419e-01  3.96171883e-01]\n",
      " [-2.94841818e-01 -1.28197243e+00  8.03701950e-02 -1.29719997e-01]\n",
      " [ 6.86617933e-02  3.37848329e-01  5.92161531e-01  7.90590793e-01]\n",
      " [ 3.10997534e-01 -5.87763531e-01  1.37235899e-01  1.33225943e-01]\n",
      " [ 5.53333275e-01 -1.28197243e+00  6.49027235e-01  3.96171883e-01]\n",
      " [ 3.10997534e-01 -5.87763531e-01  5.35295827e-01  1.75297293e-03]\n",
      " [ 6.74501145e-01 -3.56360566e-01  3.07833011e-01  1.33225943e-01]\n",
      " [ 9.16836886e-01 -1.24957601e-01  3.64698715e-01  2.64698913e-01]\n",
      " [ 1.15917263e+00 -5.87763531e-01  5.92161531e-01  2.64698913e-01]\n",
      " [ 1.03800476e+00 -1.24957601e-01  7.05892939e-01  6.59117823e-01]\n",
      " [ 1.89829664e-01 -3.56360566e-01  4.21564419e-01  3.96171883e-01]\n",
      " [-1.73673948e-01 -1.05056946e+00 -1.47092621e-01 -2.61192967e-01]\n",
      " [-4.16009689e-01 -1.51337539e+00  2.35044910e-02 -1.29719997e-01]\n",
      " [-4.16009689e-01 -1.51337539e+00 -3.33612130e-02 -2.61192967e-01]\n",
      " [-5.25060772e-02 -8.19166497e-01  8.03701950e-02  1.75297293e-03]\n",
      " [ 1.89829664e-01 -8.19166497e-01  7.62758643e-01  5.27644853e-01]\n",
      " [-5.37177559e-01 -1.24957601e-01  4.21564419e-01  3.96171883e-01]\n",
      " [ 1.89829664e-01  8.00654259e-01  4.21564419e-01  5.27644853e-01]\n",
      " [ 1.03800476e+00  1.06445364e-01  5.35295827e-01  3.96171883e-01]\n",
      " [ 5.53333275e-01 -1.74477836e+00  3.64698715e-01  1.33225943e-01]\n",
      " [-2.94841818e-01 -1.24957601e-01  1.94101603e-01  1.33225943e-01]\n",
      " [-4.16009689e-01 -1.28197243e+00  1.37235899e-01  1.33225943e-01]\n",
      " [-4.16009689e-01 -1.05056946e+00  3.64698715e-01  1.75297293e-03]\n",
      " [ 3.10997534e-01 -1.24957601e-01  4.78430123e-01  2.64698913e-01]\n",
      " [-5.25060772e-02 -1.05056946e+00  1.37235899e-01  1.75297293e-03]\n",
      " [-1.02184904e+00 -1.74477836e+00 -2.60824029e-01 -2.61192967e-01]\n",
      " [-2.94841818e-01 -8.19166497e-01  2.50967307e-01  1.33225943e-01]\n",
      " [-1.73673948e-01 -1.24957601e-01  2.50967307e-01  1.75297293e-03]\n",
      " [-1.73673948e-01 -3.56360566e-01  2.50967307e-01  1.33225943e-01]\n",
      " [ 4.32165405e-01 -3.56360566e-01  3.07833011e-01  1.33225943e-01]\n",
      " [-9.00681170e-01 -1.28197243e+00 -4.31421141e-01 -1.29719997e-01]\n",
      " [-1.73673948e-01 -5.87763531e-01  1.94101603e-01  1.33225943e-01]\n",
      " [ 5.53333275e-01  5.69251294e-01  1.27454998e+00  1.71090158e+00]\n",
      " [-5.25060772e-02 -8.19166497e-01  7.62758643e-01  9.22063763e-01]\n",
      " [ 1.52267624e+00 -1.24957601e-01  1.21768427e+00  1.18500970e+00]\n",
      " [ 5.53333275e-01 -3.56360566e-01  1.04708716e+00  7.90590793e-01]\n",
      " [ 7.95669016e-01 -1.24957601e-01  1.16081857e+00  1.31648267e+00]\n",
      " [ 2.12851559e+00 -1.24957601e-01  1.61574420e+00  1.18500970e+00]\n",
      " [-1.14301691e+00 -1.28197243e+00  4.21564419e-01  6.59117823e-01]\n",
      " [ 1.76501198e+00 -3.56360566e-01  1.44514709e+00  7.90590793e-01]\n",
      " [ 1.03800476e+00 -1.28197243e+00  1.16081857e+00  7.90590793e-01]\n",
      " [ 1.64384411e+00  1.26346019e+00  1.33141568e+00  1.71090158e+00]\n",
      " [ 7.95669016e-01  3.37848329e-01  7.62758643e-01  1.05353673e+00]\n",
      " [ 6.74501145e-01 -8.19166497e-01  8.76490051e-01  9.22063763e-01]\n",
      " [ 1.15917263e+00 -1.24957601e-01  9.90221459e-01  1.18500970e+00]\n",
      " [-1.73673948e-01 -1.28197243e+00  7.05892939e-01  1.05353673e+00]\n",
      " [-5.25060772e-02 -5.87763531e-01  7.62758643e-01  1.57942861e+00]\n",
      " [ 6.74501145e-01  3.37848329e-01  8.76490051e-01  1.44795564e+00]\n",
      " [ 7.95669016e-01 -1.24957601e-01  9.90221459e-01  7.90590793e-01]\n",
      " [ 2.24968346e+00  1.72626612e+00  1.67260991e+00  1.31648267e+00]\n",
      " [ 2.24968346e+00 -1.05056946e+00  1.78634131e+00  1.44795564e+00]\n",
      " [ 1.89829664e-01 -1.97618132e+00  7.05892939e-01  3.96171883e-01]\n",
      " [ 1.28034050e+00  3.37848329e-01  1.10395287e+00  1.44795564e+00]\n",
      " [-2.94841818e-01 -5.87763531e-01  6.49027235e-01  1.05353673e+00]\n",
      " [ 2.24968346e+00 -5.87763531e-01  1.67260991e+00  1.05353673e+00]\n",
      " [ 5.53333275e-01 -8.19166497e-01  6.49027235e-01  7.90590793e-01]\n",
      " [ 1.03800476e+00  5.69251294e-01  1.10395287e+00  1.18500970e+00]\n",
      " [ 1.64384411e+00  3.37848329e-01  1.27454998e+00  7.90590793e-01]\n",
      " [ 4.32165405e-01 -5.87763531e-01  5.92161531e-01  7.90590793e-01]\n",
      " [ 3.10997534e-01 -1.24957601e-01  6.49027235e-01  7.90590793e-01]\n",
      " [ 6.74501145e-01 -5.87763531e-01  1.04708716e+00  1.18500970e+00]\n",
      " [ 1.64384411e+00 -1.24957601e-01  1.16081857e+00  5.27644853e-01]\n",
      " [ 1.88617985e+00 -5.87763531e-01  1.33141568e+00  9.22063763e-01]\n",
      " [ 2.49201920e+00  1.72626612e+00  1.50201279e+00  1.05353673e+00]\n",
      " [ 6.74501145e-01 -5.87763531e-01  1.04708716e+00  1.31648267e+00]\n",
      " [ 5.53333275e-01 -5.87763531e-01  7.62758643e-01  3.96171883e-01]\n",
      " [ 3.10997534e-01 -1.05056946e+00  1.04708716e+00  2.64698913e-01]\n",
      " [ 2.24968346e+00 -1.24957601e-01  1.33141568e+00  1.44795564e+00]\n",
      " [ 5.53333275e-01  8.00654259e-01  1.04708716e+00  1.57942861e+00]\n",
      " [ 6.74501145e-01  1.06445364e-01  9.90221459e-01  7.90590793e-01]\n",
      " [ 1.89829664e-01 -1.24957601e-01  5.92161531e-01  7.90590793e-01]\n",
      " [ 1.28034050e+00  1.06445364e-01  9.33355755e-01  1.18500970e+00]\n",
      " [ 1.03800476e+00  1.06445364e-01  1.04708716e+00  1.57942861e+00]\n",
      " [ 1.28034050e+00  1.06445364e-01  7.62758643e-01  1.44795564e+00]\n",
      " [-5.25060772e-02 -8.19166497e-01  7.62758643e-01  9.22063763e-01]\n",
      " [ 1.15917263e+00  3.37848329e-01  1.21768427e+00  1.44795564e+00]\n",
      " [ 1.03800476e+00  5.69251294e-01  1.10395287e+00  1.71090158e+00]\n",
      " [ 1.03800476e+00 -1.24957601e-01  8.19624347e-01  1.44795564e+00]\n",
      " [ 5.53333275e-01 -1.28197243e+00  7.05892939e-01  9.22063763e-01]\n",
      " [ 7.95669016e-01 -1.24957601e-01  8.19624347e-01  1.05353673e+00]\n",
      " [ 4.32165405e-01  8.00654259e-01  9.33355755e-01  1.44795564e+00]\n",
      " [ 6.86617933e-02 -1.24957601e-01  7.62758643e-01  7.90590793e-01]]\n"
     ]
    }
   ],
   "source": [
    "from sklearn.preprocessing import StandardScaler\n",
    "X_norm = StandardScaler().fit_transform(X)\n",
    "print(X_norm)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "5.843333333333334 0.828066127977863 -4.736951571734001e-16 1.0\n"
     ]
    }
   ],
   "source": [
    "#calcualte the mean and sigma\n",
    "x1_mean = X.loc[:,'sepal length'].mean()\n",
    "x1_norm_mean = X_norm[:,0].mean()\n",
    "x1_sigma = X.loc[:,'sepal length'].std()\n",
    "x1_norm_sigma = X_norm[:,0].std()\n",
    "print(x1_mean,x1_sigma,x1_norm_mean,x1_norm_sigma)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAABH4AAAEvCAYAAAAzXwbsAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjIsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy8li6FKAAAVW0lEQVR4nO3df4xlaVkn8O/jFP4YlICZWn/M0BYmZBI0cSGdWXASwjKwgk0Y10AyRFiWXdPrZsXBmGizm8i/bTRGdzXsdgDRMA7REVZCIzL+irvJMmF6GGWGljiLLTSMDmgERZNxwuMfdYk1t6q6btW9VbfqvZ9PUqm6556q+7z3Pffcp799zrnV3QEAAABgPF+17AIAAAAAOByCHwAAAIBBCX4AAAAABiX4AQAAABiU4AcAAABgUIIfAAAAgEGtHeWD3XDDDb2xsXGUDwkAHKFLly59vrvXl10HT6YHA4CxXasHO9LgZ2NjI/fff/9RPiQAcISq6s+XXQPb6cEAYGzX6sGc6gUAAAAwKMEPAAAAwKAEPwAAAACDEvwAAAAADErwAwAAADAowQ8AAADAoAQ/AAAAAIPaM/ipqndU1WNV9dCWZd9YVfdW1Z9Ovj/jcMsEAFgtejAAYBFmOeLnnUleNrXsXJLf7e5nJ/ndyW0AABbnndGDAQBz2jP46e4/TPLXU4tvT/LLk59/Ocn3LbguAICVpgcDABbhoNf4+abufjRJJt//xeJKAgBgF3owAGBf1g77AarqbJKzSXLq1KnDfjgOyca5i0+6feX8mSVVAgDMQg928k33X4keDID9O+gRP39ZVd+SJJPvj+22Yndf6O7T3X16fX39gA8HAED0YADAPh00+HlfktdPfn59kt9cTDkAAFyDHgwA2JdZPs797iT/L8nNVXW1qv5jkvNJXlpVf5rkpZPbAAAsiB4MAFiEPa/x092v2eWu2xZcCwAAE3owAGARDnqqFwAAAADHnOAHAA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nwDXxq3aFQCCFAAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 1440x360 with 2 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "%matplotlib inline\n",
    "from matplotlib import pyplot as plt\n",
    "fig1 = plt.figure(figsize=(20,5))\n",
    "plt.subplot(121)\n",
    "plt.hist(X.loc[:,'sepal length'],bins=100)\n",
    "plt.subplot(122)\n",
    "plt.hist(X_norm[:,0],bins=100)\n",
    "\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(150, 4)\n"
     ]
    }
   ],
   "source": [
    "print(X.shape)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[0.72770452 0.23030523 0.03683832 0.00515193]\n"
     ]
    }
   ],
   "source": [
    "#pca analysis\n",
    "from sklearn.decomposition import PCA\n",
    "pca = PCA(n_components=4)\n",
    "X_pca = pca.fit_transform(X_norm)\n",
    "#calculate the variance ratio of each principle components\n",
    "var_ratio = pca.explained_variance_ratio_\n",
    "print(var_ratio)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAABI8AAAEvCAYAAADM0eFLAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjIsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy8li6FKAAAbl0lEQVR4nO3df7Bmd10f8PcnG5YfQgiaBTQb2CUEaaAQdUkCoogOQyBgRK0GFCoWYpT4oy2O247gD9oOFHUcS2Bni/HX0GbK7y1ZSRE00AJ2NxoiG41dYiBLtFkQD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5IlJrp5tImAeredeUVVnJ9mc5BPjpgPmxVruFVV1WlVdm+SmJK/r7ps3JiUwa9PeK6rqhCS/nuTnNy4d/H/KI0geWFXXJNmf5FNJfnvGeYD5tK57RVV9Y5I/SPLS7v7qiPmA+bDme0V339TdT0ry2CT/vKoesdp3gGPeWu8VP5Vkb3ffNHoyWIbH1mDyvPHigao6kOQHZ5QHmE9rvldU1UlJrkjyi9390ZHzAfNh3f9dMXnE9UCS70jytpHyAfNhrfeKpyb5jqr6qSQPTrK5qr7Y3TtHzglJrDyCIR9Icv+qevmRgap6SlU9Y4aZgPkzeK+oqs1Z2PTy97v7rTNLCMyDle4VW6vqgZOxhyX59iTXzygnMFuD94ru/pHuflR3b0vyyiz894XiiA2jPIJldHcneUGSZ01ek3kgyS8nuTlJqupDSd6a5Huq6lBVPXtmYYGZWeVe8UNJvjPJj01exXtNVZ01fDXgeLXKveKfJPnTqvpYFt6g9Gvd/RczCwvMzGp/B4FZqoX/fQIAAADAvVl5BAAAAMAg5REAAAAAg5RHAAAAAAxSHgEAAAAwSHkEAAAAwCDlEQAAAACDlEcAAAAADFIeAQAAADDo/wF9OoLpXAKmPAAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 1440x360 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "fig2 = plt.figure(figsize=(20,5))\n",
    "plt.bar([1,2,3,4],var_ratio)\n",
    "plt.xticks([1,2,3,4],['PC1','PC2','PC3','PC4'])\n",
    "plt.ylabel('variance ratio of each PC')\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(150, 2)"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pca = PCA(n_components=2)\n",
    "X_pca = pca.fit_transform(X_norm)\n",
    "X_pca.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "numpy.ndarray"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "type(X_pca)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAUkAAADUCAYAAAARBdGBAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjIsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy8li6FKAAAgAElEQVR4nO2de3iU9ZXHPyfJQAYEAkIlBBBYq7ZANIiWqmu9BmpQvIBl17YqtS7V0mirD+A1RfeBFleb7lZbay3U4hYExbbZWlT0QRTUgFxFLEVak4AimAghkNtv/5hMmJm87zv3eWcm5/M8eWDe6yGak9/vXL5HjDEoiqIo1uS4bYCiKEo6o05SURTFAXWSiqIoDqiTVBRFcUCdpKIoigPqJBVFURxwzUmKSL6IvC0im0Vku4j82C1bFEVR7BC36iRFRIDexpjDIuIB1gLlxpj1rhikKIpiQZ5bLzY+73y446On40sr2xVFSStcjUmKSK6IbAI+AV4yxrzlpj2KoiihuLaSBDDGtAFnikgB8LyIjDHGbAu8RkRuAW4B6N2791mnn366C5YqipLNbNiw4VNjzCCrc67FJEMRkQeARmPMw3bXjB8/3lRXV6fQKkVRugMissEYM97qnJvZ7UEdK0hExAtcCrzvlj2KoihWuLndLgQWi0guPme9zBjzZxftURRF6YKb2e0tQIlb71cURYkEVxM3mcjKd2tZ+Ned1NU3MaTAy10TT+OqkiK3zVIUJUmok4yCle/WMve5rTS1tAFQW9/E3Oe2AqijVJQsRXu3o2DhX3d2Okg/TS1tLPzrTpcsUpTkUrW7itLlpRQvLqZ0eSlVu6vcNinl6EoyCurqm6I6riiZTNXuKirerOBo21EA9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6bwauKyjBGg7UEGH/qSIvA48C1wiIjUikhYqR0p6oypAiqIoDuhKUlEUxQF1koqiKA6ok1QURXFAnaSiKIoD6iQVRVEcUCepKIrigDpJRVEUB9RJKoqiOPD/5rDXn5LxjJ0AAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 360x216 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "#visualize the PCA result\n",
    "fig3 = plt.figure(figsize=(5,3))\n",
    "setosa=plt.scatter(X_pca[:,0][y==0],X_pca[:,1][y==0])\n",
    "versicolor=plt.scatter(X_pca[:,0][y==1],X_pca[:,1][y==1])\n",
    "virginica=plt.scatter(X_pca[:,0][y==2],X_pca[:,1][y==2])\n",
    "plt.legend((setosa,versicolor,virginica),('setosa','versicolor','virginica'))\n",
    "plt.xlabel('PC1')\n",
    "plt.ylabel('PC2')\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [],
   "source": [
    "fig3.savefig('1.png')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0.9466666666666667\n"
     ]
    }
   ],
   "source": [
    "KNN = KNeighborsClassifier(n_neighbors=3)\n",
    "KNN.fit(X_pca,y)\n",
    "y_predict = KNN.predict(X_pca)\n",
    "from sklearn.metrics import accuracy_score\n",
    "accuracy = accuracy_score(y,y_predict)\n",
    "print(accuracy)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "raw",
   "metadata": {},
   "source": [
    "PCA实战summary：\n",
    "1、通过计算数据对应的主成分（principle components)，可在减少数据维度同时尽可能保留主要信息；\n",
    "2、为确定合适的主成分维度，可先对数据进行与原数据相同维度的PCA处理，再根据根据各个成分的数据方差确认主成分维度;\n",
    "3、核心算法参考链接：https://scikit-learn.org/stable/modules/generated/sklearn.decomposition.PCA.html?highlight=pca#sklearn.decomposition.PCA"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.10"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
